﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Text;
using Moon.Common;

public partial class Admin_SystemManage_WebAttribute : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //邮箱
            this.txtEmail.Text = Moon.Common.WebInfo.WebConfigInfo.email;
            //文件格式
            this.txtFileformat.Text = Moon.Common.WebInfo.WebConfigInfo.Fileformat;
            //图片格式
            this.txtImageformat.Text = Moon.Common.WebInfo.WebConfigInfo.Imgformat;
            //关键字
            this.txtKey.Text = Moon.Common.WebInfo.WebConfigInfo.key;
            //网站描述
            this.txtMark.Text = Moon.Common.WebInfo.WebConfigInfo.mark;
            //网站标题
            this.txtWebtitle.Text = Moon.Common.WebInfo.WebConfigInfo.title;
            //页尾
           // this.txtFootInfo.Text = new CoXmlHelper().LoadHtml(this.Context, Encoding.UTF8.ToString(), Application["WebPath"]+Moon.Common.WebInfo.WebConfigInfo.footpath);
 
        }
    }
    #region 按钮事件
    protected void btnSave_Click(object sender, EventArgs e)
    {
        object obj = Session;
        object reques = Request;

        if ("China".Equals(this.btnSave.CommandArgument))
        {
            CoXmlHelper cxh = new CoXmlHelper();
            CoXmlHelper.SaveConfigValue("email", this.txtEmail.Text);
            CoXmlHelper.SaveConfigValue("Fileformat", this.txtFileformat.Text);
            CoXmlHelper.SaveConfigValue("Imgformat", this.txtImageformat.Text);
            CoXmlHelper.SaveConfigValue("key", this.txtKey.Text);
            CoXmlHelper.SaveConfigValue("mark", this.txtMark.Text);
            CoXmlHelper.SaveConfigValue("title", this.txtWebtitle.Text);
           //写入尾部文件
          //  StringBuilder sb=new StringBuilder(this.txtFootInfo.Text);
          //  cxh.WriteHtml(this.Context, sb, Encoding.UTF8, Application["WebPath"] + Moon.Common.WebInfo.WebConfigInfo.footpath);
        }
        else
        {
            CoXmlHelper cxh = new CoXmlHelper();
            CoXmlHelper.SaveConfigValue("Eemail", this.txtEmail.Text);
            CoXmlHelper.SaveConfigValue("Fileformat", this.txtFileformat.Text);
            CoXmlHelper.SaveConfigValue("Imgformat", this.txtImageformat.Text);
            CoXmlHelper.SaveConfigValue("Ekey", this.txtKey.Text);
            CoXmlHelper.SaveConfigValue("Emark", this.txtMark.Text);
            CoXmlHelper.SaveConfigValue("Etitle", this.txtWebtitle.Text);
            //写入尾部文件
           // StringBuilder sb = new StringBuilder(this.txtFootInfo.Text);
           // cxh.WriteHtml(this.Context, sb, Encoding.UTF8, Application["WebPath"] + Moon.Common.WebInfo.WebConfigInfo.Efootpath);
        }
        Moon.Common.WebInfo.WebConfigInfo.UpdateInfo();
        MessageBox.Show(this.Page, "操作完成！");
    }
    protected void btnTab_Click(object sender, EventArgs e)
    {
        if ("China".Equals(this.btnSave.CommandArgument))
        {
            //邮箱
            this.txtEmail.Text = Moon.Common.WebInfo.WebConfigInfo.Eemail;
            //文件格式
            this.txtFileformat.Text = Moon.Common.WebInfo.WebConfigInfo.Fileformat;
            //图片格式
            this.txtImageformat.Text = Moon.Common.WebInfo.WebConfigInfo.Imgformat;
            //关键字
            this.txtKey.Text = Moon.Common.WebInfo.WebConfigInfo.Ekey;
            //网站描述
            this.txtMark.Text = Moon.Common.WebInfo.WebConfigInfo.Emark;
            //网站标题
            this.txtWebtitle.Text = Moon.Common.WebInfo.WebConfigInfo.Etitle;
            //页尾
            //this.txtFootInfo.Text = new CoXmlHelper().LoadHtml(this.Context, Encoding.UTF8.ToString(), Application["WebPath"] + Moon.Common.WebInfo.WebConfigInfo.Efootpath);
            this.btnSave.CommandArgument = "English";
            this.labVersion.Text = "英文版信息";
        }
        else
        {
            //邮箱
            this.txtEmail.Text = Moon.Common.WebInfo.WebConfigInfo.email;
            //文件格式
            this.txtFileformat.Text = Moon.Common.WebInfo.WebConfigInfo.Fileformat;
            //图片格式
            this.txtImageformat.Text = Moon.Common.WebInfo.WebConfigInfo.Imgformat;
            //关键字
            this.txtKey.Text = Moon.Common.WebInfo.WebConfigInfo.key;
            //网站描述
            this.txtMark.Text = Moon.Common.WebInfo.WebConfigInfo.mark;
            //网站标题
            this.txtWebtitle.Text = Moon.Common.WebInfo.WebConfigInfo.title;
            //页尾
        //    this.txtFootInfo.Text = new CoXmlHelper().LoadHtml(this.Context, Encoding.UTF8.ToString(), Application["WebPath"] + Moon.Common.WebInfo.WebConfigInfo.footpath);
            this.btnSave.CommandArgument = "China";
            this.labVersion.Text = "中文版信息";
        }
    }
    #endregion
}
